﻿using System;

namespace Batman.Authentication
{
    /// <summary>
    /// 标有PermissionAttribute属性的控制器Action将会被写入到权限管理系统
    /// </summary>
    [AttributeUsage(AttributeTargets.Method)]
    public class ResourceAttribute : Attribute
    {
        /// <summary>
        /// 访问路径(留空则会自动取控制器Action名称)
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// 权限名称
        /// </summary>
        public string Name { get; set; }

        public ResourceMethod Method { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 被弃用的（被标记为true后，远程系统将删除资源数据）
        /// </summary>
        public bool Abandoned { get; set; }

        /// <summary>
        /// 标记为Resful，影响资源URL处理
        /// </summary>
        public bool IsResful { get; set; }

        public ResourceAttribute(string name, string url, string remark = null, bool abandoned = false, bool isResful = false, ResourceMethod method = ResourceMethod.get)
        {
            Name = name;

            Url = url;

            Remark = remark;

            Abandoned = abandoned;

            IsResful = isResful;

            Method = method;
        }
    }
}
